Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: dto with association #583

Draft
wants to merge 4 commits into
base: 4.7.x
Choose a base branch
from
Draft

feat: dto with association #583

wants to merge 4 commits into from

Conversation

sdelamo
Copy link
Contributor

@sdelamo sdelamo commented Jun 8, 2020

No description provided.

@sdelamo
Copy link
Contributor Author

sdelamo commented Jun 8, 2020

Hello @graemerocher

Could you please check this draft PR and let me know if you think this is the right direction to go.

Sergio del Amo

@sdelamo sdelamo requested a review from graemerocher June 8, 2020 10:20
@@ -489,6 +508,18 @@ private boolean attemptProjection(@NonNull MethodMatchContext matchContext, @Non
if (pp == null) {
pp = entity.getIdOrVersionPropertyByName(propertyName);
}
SourcePersistentEntity association = null;
if (pp == null && propertyName.endsWith(DtoJoinPathsParser.CAPITALIZED_ID)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems an arbitrary limitation this endsWith check. I think entity.getPath(propertyName) should be called since if that returns a path you have a query on any property of the association.

Set<String> paths = new HashSet<>();
for (PropertyElement propertyElement : dto.getBeanProperties()) {
final String name = propertyElement.getName();
if (name.endsWith(CAPITALIZED_ID)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also limiting the capability to just properties ending with Id seems odd

@@ -101,7 +112,7 @@ public Object read(@NonNull S object, @NonNull Argument<?> argument) {
* @param property THe property
* @return The result
*/
public @Nullable Object read(@NonNull S resultSet, @NonNull RuntimePersistentProperty<T> property) {
public @Nullable Object read(@NonNull S resultSet, @NonNull RuntimePersistentProperty<?> property) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this change necessary? If the association is being queried we probably should instantiate another DTOMapper with the appropriate entity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants